<?php

class Silk_Zgb_Model_Customer extends Mage_Customer_Model_Customer 
{
	public function getName()
	{
		return $this->getFirstname();
	}

	/**
     * Load customer by firstname
     *
     * @param   string $customerFirstname
     * @return  Mage_Customer_Model_Customer
     */
    public function loadByFirstname($customerFirstname)
    {
        $this->_getResource()->loadByFirstname($this, $customerFirstname);
        return $this;
    }
    
    /**
     * Test if firstname already exists
     * 
     * @param string $firstname
     * @param int $websiteId
     */
    public function customerFirstnameExists($firstname, $websiteId = null)
    {
        if(!is_null($websiteId)){
            $this->setWebsiteId($websiteId);
        }
        
        $this->loadByFirstname($firstname);
        if ($this->getId()) {
            return $this;
        }
        return false;
    }

    /**
     * Load customer by mobile
     *
     * @param   string $mobile
     * @return  Mage_Customer_Model_Customer
     */
    public function loadByMobile($mobile)
    {
        $this->_getResource()->loadByMobile($this, $mobile);
        return $this;
    }

    /**
     * Test if mobile already exists
     *
     * @param string $mobile
     * @param int $websiteId
     */
    public function customerMobileExists($mobile, $websiteId = null)
    {
        if(!is_null($websiteId)){
            $this->setWebsiteId($websiteId);
        }

        $this->loadByMobile($mobile);
        if ($this->getId()) {
            return $this;
        }
        return false;
    }

    /**
     * Generate random confirmation key
     *
     * @return string
     */
    public function getRandomConfirmationKey()
    {
        return 1;
    }
}